<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户登录页</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

    <style>
        body {
            background-color: #f8f9fa;
            font-family: Arial, sans-serif;
        }

        .panel {
            margin-top: 50px;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        }

        .panel-heading {
            background-color: #007bff;
            color: white;
            padding: 10px 15px;
            border-top-left-radius: 5px;
            border-top-right-radius: 5px;
        }

        .panel-body {
            padding: 20px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .btn-login {
            background-color: #007bff;
            color: white;
            border: none;
        }

        .btn-login:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
<div class="container">

    <div class="panel panel-default">
        <div class="panel-heading">用户登录</div>
        <div class="panel-body">

            <form>
                <div class="form-group">
                    <label for="username">用户名:</label>
                    <input type="text" class="form-control" id="username" name="username" placeholder="请输入用户名">
                </div>
                <div class="form-group">
                    <label for="password">密码:</label>
                    <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码">
                </div>
                <button type="button" class="btn btn-login btn-block" onclick="login();">登录</button>
            </form>
        </div>
    </div>
</div>

<script>
    function login(){
        var name=$("#username").val();
        var password=$("#password").val();

        $.ajax({
            url:"/webapi/login/user",
            data:{
                username:name,
                password:password
            }
        }).done(function(rs){
            if(rs>=0){
                window.location.href="/student/list";
            }else{
                alert("出错啦，您的用户名和密码有误哦！");
            }
        });
    }
</script>

</body>
</html>